<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class authen_model extends CI_Model {

	public function checklogin($input)
	{
		$this->db->select('mem_id,mem_type');
		$this->db->from('member');
		$this->db->where('mem_name',$input['mem_name']);
		$this->db->where('mem_pass',$input['mem_pass']);
		$this->db->limit(1);
		$query = $this->db->get();

		if($query -> num_rows() == 1){
    		return $query->result_array();

  		}else{
    		return 0;
 		}
	}

	public function check_type($input)
	{
		$this->db->select('mem_id,mem_type');
		$this->db->from('member');
		$this->db->where('mem_name' ,$input['mem_name']);
		$this->db->limit(1);
		$query = $this->db->get();
		return $query->result_array();
	}

	public function check_grant($mem_id)
	{
		$this->db->select('grant_start ,grant_end');
		$this->db->from('member');
		$this->db->where('mem_id',$mem_id);
		$query = $this->db->get();

		return $query->result_array();
	}

	public function reset_grant($reset_grant)
	{
		$this->db->where('mem_id' ,$reset_grant['mem_id']);
		$this->db->update('member',$reset_grant);
	}
}